var app = getApp();
var ConstantData = require('../../common/constant_data.js')
var base64 = require('../../common/base64.js')
var BLELocker = require('../../common/BLELocker.js')

function statisticData(dataType, data) {
  console.log('statisticData---data95--->', data);
  app.executeRequest(function (header) {

    wx.request({
      url: ConstantData.CONSTATNT_DATA.BASE_URL + '/statistic/collect/data',
      header: header,
      data: {
        dt: dataType,
        data: base64.encode(data)
      },
      success: function (res) {

        console.log('上传data成功--->', dataType, data, res);
      }
    })

  })


}

function noEjectDialog(that, descMini, desc) {
  if(app.globalData._that && typeof app.globalData._that.getBleFailShowObj == 'function') {
    let failShow = app.globalData._that.getBleFailShowObj()
    that.setData({
      retryCount:that.data.retryCount+1
    })

    app.executeRequest(function (header) {
      wx.request({
        url: ConstantData.CONSTATNT_DATA.BASE_URL + '/lease/order/2/send/log/openLock',
        header: header,
        data: {
          mac: that.data.mac,
          orderCode:that.data.orderCode,
          changeLog: desc && desc instanceof Object && desc.extraData ? desc.extraData : desc,
          logDesc: ''
        },
        success: function (res) {
          console.log('开锁异常日志', res);
        }
      })
    })
    console.log('显示重试开锁==>>',that.data.retryCount,descMini,desc,that.data.orderCode)
    failShow.openFailTipShow('')
  }  
  BLELocker.disconnect('statis29');
  that.clear85Timer();
}

module.exports.statisticData = statisticData
module.exports.noEjectDialog = noEjectDialog
